package org.zcl.拒绝策略;

import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;

/**
 * @PROJECT_NAME:
 * @DESCRIPTION:
 * @USER: ZhuChengLin
 * @DATE: 2021/11/22 15:04
 */
public class ThreadPool {
    private static final Integer corePoolSize = 3;
    private static final Integer maxMumPoolSize = 5;
    private static final Integer keepAliveTime = 60000;

    public static ThreadPoolExecutor threadPool =
            new ThreadPoolExecutor(corePoolSize,
                    maxMumPoolSize,
                    keepAliveTime,
                    TimeUnit.MILLISECONDS,
                    Queue.arrayBlockingQueue,
                    RejectPolicy.discardPolicy);

    public static void main(String[] args) {
        for (int i = 1; i <= 10; i++) {
            ThreadPool.threadPool.submit(new Task(String.valueOf(i)));
        }
    }
}
